package com.kang.util;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class ConstantPropertiesUtil implements InitializingBean {

    @Value("${wx.open.app_id}")
    private String appId;

    @Value("${wx.open.app_secret}")
    private String appSecret;

    @Value("${wx.open.redirect_url}")
    private String redirectUrl;

    @Value("${base.url}")
    private String baseUrl;

    public static String WX_OPEN_APPID;
    public static String WX_OPEN_APP_SECRET;
    public static String WX_REDIRECT_UURL;
    public static String BASE_URL;

    /**
     * 加载配置文件后赋值
     * @throws Exception
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        WX_OPEN_APPID = appId;
        WX_OPEN_APP_SECRET = appSecret;
        WX_REDIRECT_UURL = redirectUrl;
        BASE_URL = baseUrl;
    }
}
